﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using DevExpress.XtraEditors;
using BussinessLayer;

namespace projectQLDV
{
    public partial class frmLopCamTinhDoan : DevExpress.XtraEditors.XtraForm
    {
        frmMain frmM;
        int idLCTD;
        tbllopcamtinhdoan LCTD = new tbllopcamtinhdoan();
        public frmLopCamTinhDoan(frmMain frm, int id, string d, string gc)
        {
            InitializeComponent();
            frmM = frm;
            idLCTD = id;
            this.dateEditNgaytochuc.Text = d;
            this.txtghichu.Text = gc;
        }

        private void btnLuu_Click(object sender, EventArgs e)
        {
            if (txtghichu.Text == "" || dateEditNgaytochuc.Text == "")
            {
                MessageBox.Show("Chưa nhập đầy đủ thông tin", "Chú Ý", MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
            else
            {
                try
                {
                    LCTD.lopcamtinhdoan(idLCTD, DateTime.Parse(dateEditNgaytochuc.Text).Date, txtghichu.Text);
                    MessageBox.Show("Lưu thành công!","Thông báo");
                }
                catch (Exception ex)
                {
                    MessageBox.Show("Error: " + ex.Message);
                }
            }
        }

        private void btnThoat_Click(object sender, EventArgs e)
        {
            this.Close();
            this.Dispose();
        }

        private void frmLopCamTinhDoan_FormClosed(object sender, FormClosedEventArgs e)
        {
            if (idLCTD == -1)
                frmM.frmThemLCTD_isShown = false;
            else frmM.frmThemLCTD_isShown = false;
        }
    }
}